<!Doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>7.3 Verilog 随机数及概率分布 | 菜鸟教程</title>

  <meta name='robots' content='max-image-preview:large' />
<link rel='stylesheet' id='classic-theme-styles-css' href='../0/classic-themes.min.css?ver=6.2' type='text/css' media='all' />
<link rel="canonical" href="../w3cnote/verilog2-random.html" />
<meta name="keywords" content="7.3 Verilog 随机数及概率分布">
<meta name="description" content="随机数 Verilog 中使用系统任务 $random(seed) 产生随机数，seed 为随机数种子。 seed 值不同，产生的随机数也不同。如果 seed 相同，产生的随机数也是一样的。 可以为 seed 赋初值，也可以忽略 seed 选项，seed 默认初始值为 0。  不使用 seed 选项和指定 seed 并对其修改来调用 $random 的代码如下所示： 实例 [mycode4 type=&#039;verilog&#039..">
		
	<link rel="shortcut icon" href="https://static.runoob.com/images/favicon.ico">
	<link rel="stylesheet" href="../0/style.css?v=1.170" type="text/css" media="all" />	
	<link rel="stylesheet" href="../0/font-awesome.min.css" media="all" />	
  <!--[if gte IE 9]><!-->
  <script src=""></script>
  <!--<![endif]-->
  <!--[if lt IE 9]>
     <script src=""></script>
     <script src=""></script>
  <![endif]-->
  <link rel="apple-touch-icon" href="https://static.runoob.com/images/icon/mobile-icon.png"/>
  <meta name="apple-mobile-web-app-title" content="菜鸟教程">
</head>
<body>

<!--  头部 -->
<div class="container logo-search">

  <div class="col search row-search-mobile">
    <form action="index.php">
      <input class="placeholder" placeholder="搜索……" name="s" autocomplete="off">
      
    </form>
  </div>

  <div class="row">
    <div class="col logo">
      <h1><a href="../">菜鸟教程 -- 学的不仅是技术，更是梦想！</a></h1>
    </div>
        <div class="col right-list"> 
    <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull" style=""> <i class="fa fa-navicon"></i> </button>
    </div>
        
    <div class="col search search-desktop last">
      <div class="search-input" >
      <form action="//www.runoob.com/" target="_blank">
        <input class="placeholder" id="s" name="s" placeholder="搜索……"  autocomplete="off" style="height: 44px;">
      </form>
      
      </div>
    </div>
  </div>
</div>



<!-- 导航栏 -->
<div class="container navigation">
    <div class="row">
        <div class="col nav">
            

                        <ul class="pc-nav" id="note-nav">
                <li><a href="../">首页</a></li>
                <li><a href="../w3cnote">笔记首页</a></li>
                <li><a href="../w3cnote/android-tutorial-intro.html" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" title="ES6 教程">ES6 教程</a></li>
                <li><a href="../w3cnote/ten-sorting-algorithm.html" title="排序算法">排序算法</a></li>
                <li><a href="../w3cnote/hadoop-tutorial.html" title="Hadoop 教程">Hadoop</a></li>
                <li><a href="../w3cnote/zookeeper-tutorial.html" title="Zookeeper 教程">Zookeeper</a></li>
                <li><a href="../w3cnote/verilog-tutorial.html" title="Verilog 教程">Verilog</a></li>
                <li><a href="../w3cnote_genre/code" title="编程技术">编程技术</a></li> 
                <li><a href="../w3cnote_genre/coderlife" title="程序员人生">程序员人生</a></li>
                
                <!--<li><a href="javascript:;" class="runoob-pop">登录</a></li>
                
                
                        <li>
                <a style="font-weight:bold;" href="../linux/linux-tutorial.html#yunserver" target="_blank" onclick="_hmt.push(['_trackEvent', 'aliyun', 'click', 'aliyun'])" title="kkb">云服务器</a>
                </li>
                <li><a href="http://gk.link/a/104mQ" target="_blank" style="font-weight: bold;"onclick="_hmt.push(['_trackEvent', '极客时间', 'click', 'jike'])" title="我的圈子">极客时间</a></li>
            
                
                <li><a target="_blank" href="../shoppinglist" rel="nofollow">知识店铺</a></li> 
        -->
            </ul>
                        
              
            <ul class="mobile-nav">
                <li><a href="../w3cnote">首页</a></li>
                <li><a href="../w3cnote_genre/android" target="_blank" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" target="_blank" title="ES6 教程">ES6</a></li>
                <li><a href="../w3cnote_genre/joke" target="_blank" title="程序员笑话">逗乐</a></li>
                
                <a href="javascript:void(0)" class="search-reveal">Search</a> 
            </ul>
            
        </div>
    </div>
</div>


<!--  内容  -->
<div class="container main">
	<div class="row">

		<!--  Android 基础入门教程 start  -->
	<div class="col left-column" style="display:none;">
		<div class="tab">Verilog 高级教程</div>
		<div class="sidebar-box gallery-list">
			<div class="design" id="leftcolumn">  
			</div> 
		</div> 
	</div>
	<!--  Android 基础入门教程 end  -->
		<div class="col middle-column big-middle-column">
	 			<div class="article">
			<div class="article-heading">
				<h2>7.3 Verilog 随机数及概率分布</h2>				<h3><em>分类</em> <a href="../w3cnote_genre/verilog2" title="Verilog 教程高级篇" >Verilog 教程高级篇</a> </h3>
			</div>
			<div class="article-body note-body">
				<div class="article-intro">
					<h3>随机数</h3><p>
Verilog 中使用系统任务 $random(seed) 产生随机数，seed 为随机数种子。</p><p>
seed 值不同，产生的随机数也不同。如果 seed 相同，产生的随机数也是一样的。</p><p>
可以为 seed 赋初值，也可以忽略 seed 选项，seed 默认初始值为 0。</p><p>

不使用 seed 选项和指定 seed 并对其修改来调用 $random 的代码如下所示：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//seed var</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">integer</span> seed <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">initial</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; seed <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">#</span><span style="color: #ff0055;">30</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; seed <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">10</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//no seed </span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; randnum_noseed <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; randnum_noseed <span style="color: #5D478B;">&lt;=</span> <span style="color: #9932CC;">$random</span><span style="color: #9F79EE;">&#40;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//不指定随机种子</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//with seed</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; randnum_wtseed <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; randnum_wtseed <span style="color: #5D478B;">&lt;=</span> <span style="color: #9932CC;">$random</span><span style="color: #9F79EE;">&#40;</span>seed<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//指定随机种子</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<p>仿真波形图如下。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-1.png"></p>
<p>无论是否赋初值，每产生一次随机数后，seed 值改变，随机数也随之改变。</p><p>
每改变一次 seed 值，当前输出的随机值会改变；但是下一个状态时，随机数的走向又恢复成系统内部产生的随机序列。</p><p>
例如仿真图中 t1 和 t2 时刻随机种子不同，产生是随机数也不同。但是其他时钟周期，产生的随机数都是相同的。</p><p>

建议调用系统任务 $random 时，不指定 seed 选项，或指定 seed 选项时使用变量传递参数。</p><p>
不建议调用 $random 时，将常数项写到 seed 参数处。此时 seed 值被固定，可能只会产生一个随机数。例如以下写法是不建议的：</p><pre>
      randnum_wtseed &lt;= $random(2); //不建议将常数项指定给 seed</pre>
<p>可以使用取余的方法，将随机数限定在一定的数据范围内。例如：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//with a range</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">parameter</span> &nbsp; &nbsp;MAX_NUM <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">512</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">parameter</span> &nbsp; &nbsp;MIN_NUM <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">256</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; num_range1<span style="color: #5D478B;">,</span> num_range2<span style="color: #5D478B;">,</span> num_range3 <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//产生的随机数范围为 -511 ~ 511, ±（MAX_NUM-1）</span><br />
&nbsp; &nbsp; &nbsp; num_range1 <span style="color: #5D478B;">&lt;=</span> <span style="color: #9932CC;">$random</span><span style="color: #9F79EE;">&#40;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">%</span> MAX_NUM<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//产生的随机数范围为 0 ~ 511, （0 ~ MAX_NUM-1）</span><br />
&nbsp; &nbsp; &nbsp; num_range2 <span style="color: #5D478B;">&lt;=</span> <span style="color: #9F79EE;">&#123;</span><span style="color: #9932CC;">$random</span><span style="color: #9F79EE;">&#40;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#125;</span> <span style="color: #5D478B;">%</span> MAX_NUM<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//产生的随机数范围为 MIN_NUM ~ MAX_NUM，包含边界</span><br />
&nbsp; &nbsp; &nbsp; num_range3 <span style="color: #5D478B;">&lt;=</span> MIN_NUM <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#123;</span><span style="color: #9932CC;">$random</span><span style="color: #9F79EE;">&#40;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#125;</span> <span style="color: #5D478B;">%</span> <span style="color: #9F79EE;">&#40;</span>MAX_NUM<span style="color: #5D478B;">-</span>MIN_NUM<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div><p>
随机数按照有符号、十进制格式显示，前几个数据结果如下：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-2.png"></p>
<hr><h2>
概率分布</h2>
<p>
Verilog 提供了许多按一定概率分布产生数据的系统任务，简单描述如下：</p>
<table class="reference"><thead><tr><th style="text-align:left;"><span>系统任务</span></th><th style="text-align:left;"><span>调用格式</span></th><th style="text-align:left;"><span>任务描述</span></th></tr></thead><tbody><tr><td style="text-align:left;"><span>均匀分布</span></td><td style="text-align:left;"><span>$dist_uniform(seed, start, end);</span></td><td style="text-align:left;"><span>start、end 为数据的起始、结尾</span></td></tr><tr><td style="text-align:left;"><span>正态分布</span></td><td style="text-align:left;"><span>$dist_normal (seed, mean, std_dev);</span></td><td style="text-align:left;"><span>mean 为期望值，std_dev 为标准差</span></td></tr><tr><td style="text-align:left;"><span>泊松分布</span></td><td style="text-align:left;"><span>$dist_poisson(seed, mean);</span></td><td style="text-align:left;"><span>mean 为期望 (等于标准差)</span></td></tr><tr><td style="text-align:left;"><span>指数分布</span></td><td style="text-align:left;"><span>$dist_exponential(seed , mean);</span></td><td style="text-align:left;"><span>mean 为单位时间内事件发生的次数</span></td></tr><tr><td style="text-align:left;"><span>卡方分布</span></td><td style="text-align:left;"><span>$dist_chi_square(seed, free_deg);</span></td><td style="text-align:left;"><span>free_deg 为自由度</span></td></tr><tr><td style="text-align:left;"><span>t 分布</span></td><td style="text-align:left;"><span>$dist_t(seed, free_deg);</span></td><td style="text-align:left;"><span>free_deg 为自由度</span></td></tr><tr><td style="text-align:left;"><span>埃尔朗分布</span></td><td style="text-align:left;"><span>$dist_erlang(seed, k_stage, mean);</span></td><td style="text-align:left;"><span>k_stage 为阶数，mean 为期望</span></td></tr></tbody></table>
<h3>
均匀分布（Uniform Distribution）</h3><p>
均匀分布在等长区间上的取值概率是相同的。</p><p>
概率密度函数及概率分布图如下所示：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-3.png" style="width: 45.33%; padding: 5px;"><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-4.png" style="width: 45.33%; padding: 5px;"></p>
<p>
其实，系统任务 $random 实现的就是均匀分布。</p><p>
调用 $dist_uniform 在（256,512）区间上产生均匀分布数据的代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//2.1 uniform dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_uniform<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span> <span style="color: #00008B; font-style: italic;">//在 MIN_NUM ~ MAX_NUM 产生随机数</span><br />
&nbsp; &nbsp; &nbsp; data_uniform <span style="color: #5D478B;">&lt;=</span> $dist_uniform<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> MIN_NUM<span style="color: #5D478B;">,</span> MAX_NUM<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<h3>正态分布（Normal Distribution）</h3><p>
正态分布数学期望为 μ，标准差为 σ，记做  <span class="marked">N (μ, σ²)</span>。</p>
<p>数学期望为 0、标准差为 1 的正态分布称为标准正态分布。</p><p>
正态分布曲线呈钟型，两边低，中间高，左右对称。</p><p>
正态分布概率密度函数及分布图如下所示：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-5.png" style="width: 45.33%; padding: 5px;"><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-6.jpeg" style="width: 45.33%; padding: 5px;"></p>
<p>调用 $dist_normal 产生期望为 0、标准差为 1 的标准正态分布数据的代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//2.2 normal dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_normal<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span> <span style="color: #00008B; font-style: italic;">//期望为0、标准差为1 的标准正态分布</span><br />
&nbsp; &nbsp; &nbsp; data_normal <span style="color: #5D478B;">&lt;=</span> $dist_normal<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">0</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<h3>泊松分布（Poisson Distribution）</h3><p>
泊松分布用于描述某个时间或空间范围内，某事件发生 X 次的概率。</p><p>
泊松分布的数学期望和标准差相同，均为 λ，其概率密度函数及分布图如下所示：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-7.png" style="width: 45.33%; padding: 5px;"><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-8.jpeg" style="width: 45.33%; padding: 5px;"></p>
<p>调用 $dist_poisson 产生期望为 4 的泊松分布数据的代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//2.3 poisson dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_poisson<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; data_poisson <span style="color: #5D478B;">&lt;=</span> $dist_poisson<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<h3>指数分布（Exponential Distribution）</h3><p>
指数分布用以描述泊松过程中随机事件发生的时间间隔的概率。泊松过程即事件以恒定的平均速率连续且独立地发生的过程。例如等公交车时两辆车到来的时间间隔，就符合指数分布。</p><p>
设 λ&gt;0 为单位时间内事件发生的次数（又称为率参数），x 为事件发生的时间间隔，则其概率密度函数及分布图如下所示：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-9.png" style="width: 45.33%; padding: 5px;"><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-10.png" style="width: 45.33%; padding: 5px;"></p>
<p>调用 $dist_exponential 产生率参数为 1 的指数分布数据的代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//2.4 exp dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_exp<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; data_exp <span style="color: #5D478B;">&lt;=</span> $dist_exponential<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<h3>
卡方分布（Chi-Square Distribution）</h3>
<p>n 个服从标准正态分布的随机变量的平方和构成新的随机变量的分布规律称为卡方分布，记做<img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-1-1.png">，其中 n 称为自由度。</p><p>
卡方分布概率密度函数及分布图如下所示：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-11.png" style="width: 45.33%; padding: 5px;"><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-12.png" style="width: 45.33%; padding: 5px;"></p>

<p>
调用 $dist_chi_square 产生自由度为 6 的卡方分布数据的代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//2.5 chi-square dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_chi_sq<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; data_chi_sq <span style="color: #5D478B;">&lt;=</span> $dist_chi_square<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<p><strong>t 分布（T-Distribution）</strong></p>
<p>假设 X 服从标准正态分布 N (0, 1)，Y 服从卡方分布<img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-1-1.png">的分布称为自由度为 n 的 t 分布,记为 Z ~ t(n) 。</p><p>
t 分布用于根据小样本来估计呈正态分布且方差未知的数据变量总体的均值。如果样本数量足够多且总体方差已知，则应该用正态分布来估计总体均值。</p><p>
t 分布是对称的钟形分布，与正态分布类似，但尾部较重，这意味着它更容易产生远低于平均值的值。其概率密度函数及分布图如下所示：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-13.png" style="width: 45.33%; padding: 5px;"><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-14.jpeg" style="width: 45.33%; padding: 5px;"></p>
<p>调用 $dist_t 产生自由度为 5 的 t 分布数据的代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//2.6 t dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_t<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; data_t <span style="color: #5D478B;">&lt;=</span> $dist_t<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<p><strong>埃尔朗分布（Erlang Distribution）</strong></p><p>
设参数为 λ 泊松过程 V1, V2, ..., V3, Vn 相互独立，N (t) 表示 [0, t) 内随机点出现的个数，则 N (t) = V1 + V2 + ... + Vn 的分布称为 Erlang 分布。</p><p>
Erlang 分布与指数分布一样，多用来表示独立随机事件发生的时间间隔。遵循 Erlang 分布的随机变量可以被分解为多个相同参数的指数分布的随机变量之和，使得 Erlang 分布被广泛应用于可靠性理论和排队论中。</p><p>
Erlang 分布概率密度函数及分布图如下所示：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-15.png" style="width: 45.33%; padding: 5px;"><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-16.jpeg" style="width: 45.33%; padding: 5px;"></p>
<p>Why The Face? 你竟然拿这样的水果 idea 来充数 Erlang 分布？</p><p>
上述概率分布任务都只列举了调用方法，并没有对数据进行分析验证。下面有介绍借助 Matlab 画图工具，自己动手去分析概率分布任务 $dist_erlang 所产生数据的特性。</p><p>
调用 $dist_erlang 产生阶数为 3、期望为 6 的 Erlang 分布数据的代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//2.7 Erlang dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_erlang<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; data_erlang <span style="color: #5D478B;">&lt;=</span> $dist_erlang<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">3</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div><hr>
<h2>
数据分析</h2><p>
现实证明，还是熟知的分布数据分析起来比较方便。一些平台关于 Erlang 分布相关的可参考性集成函数是少之又少。明知没有爱（尔朗），偏向爱而行！</p>
<h3>Verilog 数据文件</h3><p>
首先，在 Verilog 模型中产生 4 组服从 Erlang 分布的数据，并打印到文件中。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//generating data file of Erlang dis</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">integer</span> fd1<span style="color: #5D478B;">,</span> fd2<span style="color: #5D478B;">,</span> fd3<span style="color: #5D478B;">,</span> fd30 <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">initial</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; fd1 <span style="color: #5D478B;">=</span> <span style="color: #9932CC;">$fopen</span><span style="color: #9F79EE;">&#40;</span><span style="color: #FF00FF;">&quot;data_erlang1.hex&quot;</span><span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;w&quot;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; fd2 <span style="color: #5D478B;">=</span> <span style="color: #9932CC;">$fopen</span><span style="color: #9F79EE;">&#40;</span><span style="color: #FF00FF;">&quot;data_erlang2.hex&quot;</span><span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;w&quot;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; fd3 <span style="color: #5D478B;">=</span> <span style="color: #9932CC;">$fopen</span><span style="color: #9F79EE;">&#40;</span><span style="color: #FF00FF;">&quot;data_erlang3.hex&quot;</span><span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;w&quot;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; fd30 <span style="color: #5D478B;">=</span> <span style="color: #9932CC;">$fopen</span><span style="color: #9F79EE;">&#40;</span><span style="color: #FF00FF;">&quot;data_erlang30.hex&quot;</span><span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;w&quot;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">repeat</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1000</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span> <span style="color: #00008B; font-style: italic;">//取1000个数据分析</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">#</span><span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9932CC;">$fdisplay</span><span style="color: #9F79EE;">&#40;</span>fd1<span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;%h&quot;</span><span style="color: #5D478B;">,</span> data_erlang1<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9932CC;">$fdisplay</span><span style="color: #9F79EE;">&#40;</span>fd2<span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;%h&quot;</span><span style="color: #5D478B;">,</span> data_erlang2<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9932CC;">$fdisplay</span><span style="color: #9F79EE;">&#40;</span>fd3<span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;%h&quot;</span><span style="color: #5D478B;">,</span> data_erlang3<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9932CC;">$fdisplay</span><span style="color: #9F79EE;">&#40;</span>fd30<span style="color: #5D478B;">,</span> <span style="color: #FF00FF;">&quot;%h&quot;</span><span style="color: #5D478B;">,</span> data_erlang30<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #9932CC;">$fclose</span><span style="color: #9F79EE;">&#40;</span>fd1<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #9932CC;">$fclose</span><span style="color: #9F79EE;">&#40;</span>fd2<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #9932CC;">$fclose</span><span style="color: #9F79EE;">&#40;</span>fd3<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #9932CC;">$fclose</span><span style="color: #9F79EE;">&#40;</span>fd30<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_erlang1<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_erlang2<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_erlang3<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; data_erlang30<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; data_erlang1 &nbsp;<span style="color: #5D478B;">&lt;=</span> $dist_erlang<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; data_erlang2 &nbsp;<span style="color: #5D478B;">&lt;=</span> $dist_erlang<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">2</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; data_erlang3 &nbsp;<span style="color: #5D478B;">&lt;=</span> $dist_erlang<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">3</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; data_erlang30 <span style="color: #5D478B;">&lt;=</span> $dist_erlang<span style="color: #9F79EE;">&#40;</span>seed_dis<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">30</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<h3>Verilog 数据分析</h3><p>
Matlab 中可以使用柱状图函数 hist 直接对各个数据进行统计画图显示，但对于概率分布情况该函数实际画图效果并不是很好（欢迎提供良好的画图方法）。这里使用 Matlab 数量统计函数 tabulate 对各个数据进行统计，然后使用普通画图函数 plot 显示其百分比。</p><p>
Matlab 读取 Verilog 模块产生的数据并对其进行分布图显示的代码如下。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
clear all<span style="color: #5D478B;">;</span>close all<span style="color: #5D478B;">;</span>clc<span style="color: #5D478B;">;</span><br />
<span style="color: #5D478B;">%=======================================================</span><br />
<span style="color: #5D478B;">%</span> data analysis from $dist_erlang in Verilog<br />
<span style="color: #5D478B;">%=======================================================</span><br />
<br />
<span style="color: #5D478B;">%</span>按字符串读取，再进行十六进制到十进制的转换<br />
data_erlang1_hex &nbsp; &nbsp;<span style="color: #5D478B;">=</span> textread<span style="color: #9F79EE;">&#40;</span>'data_erlang1.hex'<span style="color: #5D478B;">,</span> '<span style="color: #5D478B;">%</span>s'<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
data_erlang2_hex &nbsp; &nbsp;<span style="color: #5D478B;">=</span> textread<span style="color: #9F79EE;">&#40;</span>'data_erlang2.hex'<span style="color: #5D478B;">,</span> '<span style="color: #5D478B;">%</span>s'<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
data_erlang3_hex &nbsp; &nbsp;<span style="color: #5D478B;">=</span> textread<span style="color: #9F79EE;">&#40;</span>'data_erlang3.hex'<span style="color: #5D478B;">,</span> '<span style="color: #5D478B;">%</span>s'<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
data_erlang30_hex &nbsp; <span style="color: #5D478B;">=</span> textread<span style="color: #9F79EE;">&#40;</span>'data_erlang30.hex'<span style="color: #5D478B;">,</span> '<span style="color: #5D478B;">%</span>s'<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
data_erlang1 &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> hex2dec<span style="color: #9F79EE;">&#40;</span>data_erlang1_hex<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
data_erlang2 &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> hex2dec<span style="color: #9F79EE;">&#40;</span>data_erlang2_hex<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
data_erlang3 &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> hex2dec<span style="color: #9F79EE;">&#40;</span>data_erlang3_hex<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
data_erlang30 &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">=</span> hex2dec<span style="color: #9F79EE;">&#40;</span>data_erlang30_hex<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
<br />
<span style="color: #5D478B;">%</span>统计数据数量，并画图显示<br />
num_erlang1 &nbsp;<span style="color: #5D478B;">=</span> tabulate<span style="color: #9F79EE;">&#40;</span>data_erlang1<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
num_erlang2 &nbsp;<span style="color: #5D478B;">=</span> tabulate<span style="color: #9F79EE;">&#40;</span>data_erlang2<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
num_erlang3 &nbsp;<span style="color: #5D478B;">=</span> tabulate<span style="color: #9F79EE;">&#40;</span>data_erlang3<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
num_erlang30 <span style="color: #5D478B;">=</span> tabulate<span style="color: #9F79EE;">&#40;</span>data_erlang30<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
figure<span style="color: #5D478B;">;</span> &nbsp;plot<span style="color: #9F79EE;">&#40;</span>num_erlang1<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">/</span><span style="color: #ff0055;">6</span><span style="color: #5D478B;">,</span> num_erlang1<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
hold on<span style="color: #5D478B;">;</span> plot<span style="color: #9F79EE;">&#40;</span>num_erlang2<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">/</span><span style="color: #ff0055;">6</span><span style="color: #5D478B;">,</span> num_erlang2<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> 'r'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
hold on<span style="color: #5D478B;">;</span> plot<span style="color: #9F79EE;">&#40;</span>num_erlang3<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">/</span><span style="color: #ff0055;">6</span><span style="color: #5D478B;">,</span> num_erlang3<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> 'g'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
hold on<span style="color: #5D478B;">;</span> plot<span style="color: #9F79EE;">&#40;</span>num_erlang30<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">/</span><span style="color: #ff0055;">6</span><span style="color: #5D478B;">,</span> num_erlang30<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:,</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> 'y'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
legend<span style="color: #9F79EE;">&#40;</span>'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">1</span>'<span style="color: #5D478B;">,</span> 'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">2</span>'<span style="color: #5D478B;">,</span> 'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">3</span>'<span style="color: #5D478B;">,</span> 'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">30</span>'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
</div></div><p>
Verilog 模型产生的 Erlang 数据分布图如下所示。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-17.png"></p>
<h3>Erlang 分布期望</h3><p>
千万要注意的是，λ 参数是泊松分布的期望，而不是 Erlang 分布的期望。</p><p>
Verilog 系统任务 $dist_erlang(seed, k_stage, mean) 中第三个参数为期望值。如果直接将期望值带入到 λ 参数，将得到错误的分布结果。</p><p>
下面简（偷）单（懒）推（参）导（考）下 Erlang 分布的数学期望。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-18.png" width="50%"></p>
<p>附 Erlang 分布方差的推导过程。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-19.png" width="50%"></p>
<h3>Matlab 理论分布</h3><p>
使用 Matlab 内置函数 random，可以产生多种类型的分布数据，然而偏偏没有 Erlang 分布。</p><p>
下面利用概率密度分布函数产生服从 Erlang 分布的数据。</p><p>
其中，Verilog 模型中期望值为 6，则实际参数 λ = n/6 。 </p><p>
Matlab 产生 Erlang 分布数据的代码如下。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
clear all<span style="color: #5D478B;">;</span>close all<span style="color: #5D478B;">;</span>clc<span style="color: #5D478B;">;</span><br />
<span style="color: #5D478B;">%=======================================================</span><br />
<span style="color: #5D478B;">%</span> generating data of Erlang distribution <br />
<span style="color: #5D478B;">%=======================================================</span><br />
NUM &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">400</span> <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">EXPECT</span> &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">6</span> <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">for</span> n<span style="color: #5D478B;">=</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">2</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">3</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">30</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//产生4组数据</span><br />
&nbsp; &nbsp; lamda &nbsp; <span style="color: #5D478B;">=</span> n<span style="color: #5D478B;">/</span><span style="color: #A52A2A; font-weight: bold;">EXPECT</span><span style="color: #5D478B;">;</span> &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//期望值转换</span><br />
&nbsp; &nbsp; t &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">0</span><span style="color: #5D478B;">:</span>NUM<span style="color: #5D478B;">-</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span><span style="color: #ff0055;">0.1</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; pt<span style="color: #9F79EE;">&#40;</span>n<span style="color: #5D478B;">,:</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>lamda<span style="color: #9F79EE;">&#41;</span>.<span style="color: #5D478B;">^</span>n <span style="color: #5D478B;">*</span><span style="color: #9F79EE;">&#40;</span>t<span style="color: #9F79EE;">&#41;</span>.<span style="color: #5D478B;">^</span><span style="color: #9F79EE;">&#40;</span>n<span style="color: #5D478B;">-</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">/</span>factorial<span style="color: #9F79EE;">&#40;</span>n<span style="color: #5D478B;">-</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> .<span style="color: #5D478B;">*</span> exp<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">-</span>lamda <span style="color: #5D478B;">*</span> t<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
figure<span style="color: #5D478B;">;</span> plot<span style="color: #9F79EE;">&#40;</span>t<span style="color: #5D478B;">,</span> pt<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">,:</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span><span style="color: #ff0055;">100</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
hold on<span style="color: #5D478B;">;</span>plot<span style="color: #9F79EE;">&#40;</span>t<span style="color: #5D478B;">,</span> pt<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #5D478B;">,:</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span><span style="color: #ff0055;">100</span><span style="color: #5D478B;">,</span> 'r'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
hold on<span style="color: #5D478B;">;</span>plot<span style="color: #9F79EE;">&#40;</span>t<span style="color: #5D478B;">,</span> pt<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">,:</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span><span style="color: #ff0055;">100</span><span style="color: #5D478B;">,</span> 'g'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
hold on<span style="color: #5D478B;">;</span>plot<span style="color: #9F79EE;">&#40;</span>t<span style="color: #5D478B;">,</span> pt<span style="color: #9F79EE;">&#40;</span>n<span style="color: #5D478B;">,:</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span><span style="color: #ff0055;">100</span><span style="color: #5D478B;">,</span> 'y'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
xlabel<span style="color: #9F79EE;">&#40;</span>'t'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
ylabel<span style="color: #9F79EE;">&#40;</span>'f<span style="color: #9F79EE;">&#40;</span>t<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">/</span> <span style="color: #ff0055;">100</span><span style="color: #5D478B;">%</span>'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
legend<span style="color: #9F79EE;">&#40;</span>'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">1</span>'<span style="color: #5D478B;">,</span> 'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">2</span>'<span style="color: #5D478B;">,</span> 'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">3</span>'<span style="color: #5D478B;">,</span> 'n<span style="color: #5D478B;">=</span><span style="color: #ff0055;">30</span>'<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
</div></div>

<p>Matlab 产生 Erlang 的数据分布图如下所示。</p><p>
对比 Verilog 模型产生的数据，两者的分布区间、分布概率及分布曲线走势基本是一致的。只是 Verilog 中产生的是时间间隔较大的数据，分布图不是平滑的曲线。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2021/05/v-random-20.png" width="50%"></p>
<h3>本章节源码下载</h3><p>
<a class="download" href="../wp-content/uploads/2021/05/v7.3-random.zip">Download</a>   </p>				</div>
			</div>
			<div class="previous-next-links">
			<div class="previous-design-link">← <a href="../w3cnote/verilog2-file.html" rel="prev"> 7.2 Verilog 文件操作</a> </div>
			<div class="next-design-link"><a href="../w3cnote/verilog2-real2int.html" rel="next"> 7.4 Verilog 实数整数转换</a> →</div>
			</div>
						<div class="article-heading-ad" id="w3cnote-ad728">
			<script async src=""></script>
			<!-- 移动版 自动调整 -->
			<ins class="adsbygoogle"
			     style="display:inline-block;min-width:300px;max-width:970px;width:100%;height:90px"
			     data-ad-client="ca-pub-5751451760833794"
			     data-ad-slot="1691338467"
			     data-ad-format="horizontal"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>
			</div>
			<style>
@media screen and (max-width: 768px) {
	#w3cnote-ad728 {
		display: none;
	}
}
p.note-author {
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    font-weight: bold;
    color: #78a15a;
    padding-bottom: 2px;
    margin-bottom: 4px;
}
</style>
<script>
var aid = 23825;
</script>
	</div>
		
	</div>
	<div class="listcol last right-column">

	<script type="text/javascript">
jQuery(document).ready(function ($){
	var total = $(".membership li").length;
	var left_list = '';
	href = window.location.href;
	
	$(".membership li").each(function(index, value){

		left_list += $(this).html();

		cur_href = $(this).find("a").attr("href");
		cur_obj = $(this);
		
		if(href.match(cur_href) != null) {
			if(index==0) {
				$(".previous-design-link").hide();
			}
			if(index==(total-1)) {
				$(".next-design-link").hide();
			}
			prev_href = cur_obj.prev("li").find("a").attr("href");
			prev_title = cur_obj.prev("li").find("a").attr("title");

			next_href = cur_obj.next("li").find("a").attr("href");
			next_title = cur_obj.next("li").find("a").attr("title");
			if(prev_title) {
				$(".previous-design-link a").attr("href", prev_href);
				$(".previous-design-link a").attr("title", prev_title);
				$(".previous-design-link a").text(prev_title);
			} else {
				$(".previous-design-link").html("");
			}

			if(next_title) {
				$(".next-design-link a").attr("href", next_href);
				$(".next-design-link a").attr("title", next_title);
				$(".next-design-link a").text(next_title);
			} else {
				$(".next-design-link").html("");
			}
		}
	});

	$("#leftcolumn").html(left_list);
});
	</script>
	<div class="sidebar-box cate-list">
	<div class="sidebar-box recommend-here list-link">
	<a href="javascript:void(0);">Verilog 高级教程</a>	</div>
	
	<ul class="membership">
		
	<li><a target="_top" data-id="23639" title="0.1 数字逻辑设计" href="../w3cnote/verilog2-tutorial.html" >0.1 数字逻辑设计</a></li>
	
		
	<li><a target="_top" data-id="23641" title="0.2 Verilog 编码风格" href="../w3cnote/verilog2-codestyle.html" >0.2 Verilog 编码风格</a></li>
	
		
	<li><a target="_top" data-id="23644" title="0.3 Verilog 代码规范" href="../w3cnote/verilog2-codeguide.html" >0.3 Verilog 代码规范</a></li>
	
		
	<li><a target="_top" data-id="23645" title="1.1 Verilog 门的类型" href="../w3cnote/verilog2-gate.html" >1.1 Verilog 门的类型</a></li>
	
		
	<li><a target="_top" data-id="23648" title="1.2 Verilog 开关级建模" href="../w3cnote/verilog2-level-modeling.html" >1.2 Verilog 开关级建模</a></li>
	
		
	<li><a target="_top" data-id="23656" title="1.3 Verilog 门延迟" href="../w3cnote/verilog2-gate-delay.html" >1.3 Verilog 门延迟</a></li>
	
		
	<li><a target="_top" data-id="23673" title="2.1 Verilog UDP 基础知识" href="../w3cnote/verilog2-udp.html" >2.1 Verilog UDP 基础知识</a></li>
	
		
	<li><a target="_top" data-id="23674" title="2.2 Verilog 组合逻辑 UDP" href="../w3cnote/verilog2-udp-logic.html" >2.2 Verilog 组合逻辑 UDP</a></li>
	
		
	<li><a target="_top" data-id="23677" title="2.3 Verilog 时序逻辑 UDP" href="../w3cnote/verilog2-udp-timing.html" >2.3 Verilog 时序逻辑 UDP</a></li>
	
		
	<li><a target="_top" data-id="23685" title="3.1 Verilog 延迟模型" href="../w3cnote/verilog2-delay-type.html" >3.1 Verilog 延迟模型</a></li>
	
		
	<li><a target="_top" data-id="23690" title="3.2 Verilog specify 块语句" href="../w3cnote/verilog2-specify.html" >3.2 Verilog specify 块语句</a></li>
	
		
	<li><a target="_top" data-id="23692" title="3.3 Verilog 建立时间和保持时间" href="../w3cnote/verilog2-setup-hold-time.html" >3.3 Verilog 建立时间和保持时间</a></li>
	
		
	<li><a target="_top" data-id="23701" title="3.4 Verilog 时序检查" href="../w3cnote/verilog2-timing-check.html" >3.4 Verilog 时序检查</a></li>
	
		
	<li><a target="_top" data-id="23708" title="3.5 Verilog 延迟反标注" href="../w3cnote/verilog2-sdf.html" >3.5 Verilog 延迟反标注</a></li>
	
		
	<li><a target="_top" data-id="23714" title="4.1 Verilog 同步与异步" href="../w3cnote/verilog-sync.html" >4.1 Verilog 同步与异步</a></li>
	
		
	<li><a target="_top" data-id="23725" title="4.2 Verilog 跨时钟域传输：慢到快" href="../w3cnote/verilog2-slow2fast.html" >4.2 Verilog 跨时钟域传输：慢到快</a></li>
	
		
	<li><a target="_top" data-id="23729" title="4.3 Verilog 跨时钟域传输：快到慢" href="../w3cnote/verilog2-fast2slow.html" >4.3 Verilog 跨时钟域传输：快到慢</a></li>
	
		
	<li><a target="_top" data-id="23731" title="4.4 Verilog FIFO 设计" href="../w3cnote/verilog2-fifo.html" >4.4 Verilog FIFO 设计</a></li>
	
		
	<li><a target="_top" data-id="23739" title="5.1 Verilog 复位简介" href="../w3cnote/verilog2-reset.html" >5.1 Verilog 复位简介</a></li>
	
		
	<li><a target="_top" data-id="23743" title="5.2 Verilog 时钟简介" href="../w3cnote/verilog2-clock.html" >5.2 Verilog 时钟简介</a></li>
	
		
	<li><a target="_top" data-id="23757" title="5.3 Verilog 时钟分频" href="../w3cnote/verilog2-clock-division.html" >5.3 Verilog 时钟分频</a></li>
	
		
	<li><a target="_top" data-id="23768" title="5.4 Verilog 时钟切换" href="../w3cnote/verilog2-clock-switch.html" >5.4 Verilog 时钟切换</a></li>
	
		
	<li><a target="_top" data-id="23779" title="6.1 Verilog 低功耗简介" href="../w3cnote/verilog2-low-power.html" >6.1 Verilog 低功耗简介</a></li>
	
		
	<li><a target="_top" data-id="23788" title="6.2 Verilog 系统级低功耗设计" href="../w3cnote/verilog2-lower-power-design.html" >6.2 Verilog 系统级低功耗设计</a></li>
	
		
	<li><a target="_top" data-id="23792" title="6.3 Verilog  RTL 级低功耗设计（上）" href="../w3cnote/verilog2-rtl-low-power-design-1.html" >6.3 Verilog  RTL 级低功耗设计（上）</a></li>
	
		
	<li><a target="_top" data-id="23796" title="6.4 Verilog RTL 级低功耗设计（下）" href="../w3cnote/verilog2-rtl-low-power-design-2.html" >6.4 Verilog RTL 级低功耗设计（下）</a></li>
	
		
	<li><a target="_top" data-id="23806" title="7.1 Verilog 显示任务" href="../w3cnote/verilog2-display.html" >7.1 Verilog 显示任务</a></li>
	
		
	<li><a target="_top" data-id="23813" title="7.2 Verilog 文件操作" href="../w3cnote/verilog2-file.html" >7.2 Verilog 文件操作</a></li>
	
		<li>
	7.3 Verilog 随机数及概率分布	</li>
	
		
	<li><a target="_top" data-id="23847" title="7.4 Verilog 实数整数转换" href="../w3cnote/verilog2-real2int.html" >7.4 Verilog 实数整数转换</a></li>
	
		
	<li><a target="_top" data-id="23851" title="7.5 Verilog 其他系统任务" href="../w3cnote/verilog2-other-task.html" >7.5 Verilog 其他系统任务</a></li>
	
		
	<li><a target="_top" data-id="23862" title="8.1 Verilog  PLI 简介" href="../w3cnote/verilog2-pli-intro.html" >8.1 Verilog  PLI 简介</a></li>
	
		
	<li><a target="_top" data-id="23865" title="8.2 Verilog TF 子程序" href="../w3cnote/verilog2-tf.html" >8.2 Verilog TF 子程序</a></li>
	
		
	<li><a target="_top" data-id="23869" title="8.3 Verilog TF 子程序列表" href="../w3cnote/verilog2-tf-sub.html" >8.3 Verilog TF 子程序列表</a></li>
	
		
	<li><a target="_top" data-id="23870" title="8.4 Verilog ACC 子程序" href="../w3cnote/verilog2-acc.html" >8.4 Verilog ACC 子程序</a></li>
	
		
	<li><a target="_top" data-id="23872" title="8.5 Verilog ACC 子程序列表" href="../w3cnote/verilog2-acc-sub.html" >8.5 Verilog ACC 子程序列表</a></li>
	
		
	<li><a target="_top" data-id="23876" title="9.1 Verilog 逻辑综合" href="../w3cnote/verilog2-logic-sumarry.html" >9.1 Verilog 逻辑综合</a></li>
	
		
	<li><a target="_top" data-id="23882" title="9.2 Verilog 可综合性设计" href="../w3cnote/verilog2-integrated-design.html" >9.2 Verilog 可综合性设计</a></li>
	
	</ul></div>	</div>
</div>


<!-- 底部 -->
<div id="footer" class="mar-t50">
   <div class="runoob-block">
    <div class="runoob cf">
     <dl>
      <dt>
       在线实例
      </dt>
      <dd>
       &middot;<a target="_blank" href="../html/html-examples.html">HTML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../css/css-examples.html">CSS 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../js/js-examples.html">JavaScript 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../ajx/ajax-examples.html">Ajax 实例</a>
      </dd>
       <dd>
       &middot;<a target="_blank" href="../jquery/jquery-examples.html">jQuery 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../xml/xml-examples.html">XML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../java/java-examples.html">Java 实例</a>
      </dd>
     
     </dl>
     <dl>
      <dt>
      字符集&工具
      </dt>
      <dd>
       &middot; <a target="_blank" href="../charsets/html-charsets.html">HTML 字符集设置</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-ascii.html">HTML ASCII 字符集</a>
      </dd>
     <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6939/">JS 混淆/加密</a>
      </dd> 
      <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6232/">PNG/JPEG 图片压缩</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-colorpicker.html">HTML 拾色器</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/53">JSON 格式化工具</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/6680/">随机数生成器</a>
      </dd>
     </dl>
     <dl>
      <dt>
       最新更新
      </dt>
                   <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imread.html" title="Matplotlib imread() 方法">Matplotlib imre...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imsave.html" title="Matplotlib imsave() 方法">Matplotlib imsa...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imshow.html" title="Matplotlib imshow() 方法">Matplotlib imsh...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-hist.html" title="Matplotlib 直方图">Matplotlib 直方图</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-func-object.html" title="Python object() 函数">Python object()...</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-ai-draw.html" title="Python AI 绘画">Python AI 绘画</a>
      </dd>
              <dd>
       &middot;
      <a href="../w3cnote/cursor-editor.html" title="神辅助 Cursor 编辑器，加入 GPT-4 让编码更轻松！">神辅助 Cursor ...</a>
      </dd>
             </dl>
     <dl>
      <dt>
       站点信息
      </dt>
      <dd>
       &middot;
       <a target="_blank" href="mailto:admin@runoob.com" rel="external nofollow">意见反馈</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../disclaimer">免责声明</a>
       </dd>
      <dd>
       &middot;
       <a target="_blank" href="../aboutus">关于我们</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../archives">文章归档</a>
      </dd>
    
     </dl>
    
     <div class="search-share">
      <div class="app-download">
        <div>
         <strong>关注微信</strong>
        </div>
      </div>
      <div class="share">
      <img width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png" />
       </div>
     </div>
     
    </div>
   </div>
   <div class="w-1000 copyright">
     Copyright &copy; 2013-2023    <strong><a href="../" target="_blank">菜鸟教程</a></strong>&nbsp;
    <strong><a href="../" target="_blank">runoob.com</a></strong> All Rights Reserved. 备案号：<a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/">闽ICP备15012807号-1</a>
   </div>
  </div>
  <div class="fixed-btn">
    <a class="go-top" href="javascript:void(0)" title="返回顶部"> <i class="fa fa-angle-up"></i></a>
    <a class="qrcode"  href="javascript:void(0)" title="关注我们"><i class="fa fa-qrcode"></i></a>
    <a class="writer" style="display:none" href="javascript:void(0)"   title="标记/收藏"><i class="fa fa-star" aria-hidden="true"></i></a>
    <!-- qrcode modal -->
    <div id="bottom-qrcode" class="modal panel-modal hide fade in">
      <h4>微信关注</h4>
      <div class="panel-body"><img alt="微信关注" width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png"></div> 
    </div>
  </div>

 <div style="display:none;">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84264393-2"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-84264393-2');
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3eec0b7da6548cf07db3bc477ea905ee";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</div>
<script>
window.jsui={
    www: 'https://www.runoob.com',
    uri: 'https://www.runoob.com/wp-content/themes/runoob'
};
</script>

<script src=""></script>
<script src=""></script>

</body>
</html>